//
//  CustomStackView.m
//  NewiOSProject
//
//  Created by li on 2023/9/5.
//  Copyright © 2023 范智渊. All rights reserved.
//

#import "CustomStackView.h"
@interface CustomStackView()
@end

@implementation CustomStackView

+ (CustomStackView *)init:(UILayoutConstraintAxis)axis {
    CustomStackView *stackView = [CustomStackView new];
    stackView.axis = axis;
    return stackView;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self insertSubview:self.backgroundView atIndex:0];

    }
    return self;
}

- (void)setCustomBackgroundColor:(UIColor *)color {
    
    if (@available(iOS 14, *)) {
        self.backgroundColor = color;
    }else {
        self.backgroundView.backgroundColor = color;
    }
}

- (UIImageView *)backgroundView {
    if (!_backgroundView) {
        self.backgroundView = [UIImageView new];
        _backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        _backgroundView.userInteractionEnabled = NO;
    }
    return _backgroundView;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
